package com.hao.demo.hazelcast.util.map.impl;

import com.hao.demo.hazelcast.util.map.MapService;
import com.hazelcast.core.HazelcastInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class MapServiceImpl implements MapService {

    @Qualifier("hazelcastInstance")
    @Autowired
    private HazelcastInstance instance;

    @Override
    public void put(String key, Object value) {
        Map<String, Object> map = instance.getMap("demo");
        map.put(key, value);
    }

    @Override
    public Object get(String key) {
        Map<String, Object> map = instance.getMap("demo");
        Object value = map.get(key);
        return value;
    }
}
